package com.fuqi.android.zhongcai.base.view.adapter;

import android.content.Context;
import android.os.Bundle;
import android.view.View;

import com.fuqi.android.zhongcai.R;
import com.fuqi.android.zhongcai.business.shuig.request.result.CheckInfoListResult;
import com.fuqi.android.zhongcai.business.shuig.view.activity.ChouChaShowActivity;
import com.fuqi.android.zhongcai.utils.ActivityUtils;
import com.fuqi.framework.utils.StringUtil;

import java.util.List;

/**
 * create by juner
 * @Date 2016-8-31
 */


public class MonthChouChaAdapter extends BaseRecyclerViewAdapter<CheckInfoListResult>{
    Context mContext;

    public MonthChouChaAdapter(Context mContext ,List<CheckInfoListResult> datas) {
        super(datas);
        this.mContext = mContext;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.adapter_yi_choucha;
    }

    @Override
    protected void onBind(ViewHolder holder, int position,CheckInfoListResult data) {
        holder.setTextView(R.id.tv_order_origin, data.getORDER_COMEFROM());
        holder.getTextView(R.id.btn_order_status).setTag(data.getORDER_ID());
        if(hasPunish(data.getPUNISH_AMOUNT())) {
            holder.setTextView(R.id.tv_order_status, "有");
            holder.getTextView(R.id.btn_order_status).setVisibility(View.VISIBLE);
        }else{
            holder.setTextView(R.id.tv_order_status, "无");
            holder.getTextView(R.id.btn_order_status).setVisibility(View.GONE);
        }
        holder.getTextView(R.id.btn_order_status).setOnClickListener(listener);
        holder.setTextView(R.id.tv_install_address, data.getADDR_AREA() + data.getADDR_AREA() + data.getADDR_AREA() + " " + data.getADDR_DETAIL());
    }

    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Bundle bundle = new Bundle();
            bundle.putString("order_id",v.getTag().toString());
            ActivityUtils.startActivity(mContext.getApplicationContext(), ChouChaShowActivity.class, bundle);
        }
    };

    boolean hasPunish(String punishAmount){
        int iAmount = StringUtil.parseInt(punishAmount);
        if(iAmount > 0) return true;
        return false;
    }
}
